/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import { BasicPagination, isInvalidObject, compareNum, TableCustomize, openSuccessModal, openModalMessage, compareString } from '../../../components/TableCustomize'
import * as BillManageService from '../../../axios/BillManage'
import {
    Row,
    Col,
    Form,
    Select,
    Layout,
    List,
    Button,
    Pagination,
    Cascader,
    Input,
    Alert,
    Spin,
    DatePicker,
    Radio
} from 'antd';
const FormItem = Form.Item;
const { Header, Footer, Sider, Content } = Layout;
const { Option } = Select
const { TextArea } = Input

const AddSelfChecking = ({ form: { getFieldDecorator }, modelData, procedureData, StartOrStopList }) => {

    const formItemLayout = {
        // 抽屉里面Form。二列的布局比例
        labelCol: {
            span: 8
        },
        wrapperCol: {
            span: 12
        }
    };
    return (
        <Form>
            <FormItem {...formItemLayout} label={'表单编码'}>
                {getFieldDecorator('formCode', {
                    rules: [
                        {
                            required: true,
                            message: '请输入表单编码'
                        }
                    ],
                    getValueFromEvent: (event) => {
                        return event.target.value.replace(/\s+/g, "")
                    },
                })(<Input placeholder='请输入表单编码' allowClear />)}
            </FormItem>
            <FormItem {...formItemLayout} label={'表单名称'}>
                {getFieldDecorator('formName', {
                    rules: [
                        {
                            required: true,
                            message: '请输入表单名称'
                        }
                    ],
                    getValueFromEvent: (event) => {
                        return event.target.value.replace(/\s+/g, "")
                    },
                })(<Input placeholder='请输入表单名称' allowClear />)}
            </FormItem>
            <FormItem {...formItemLayout} label={'适用机型'}>
                {getFieldDecorator('model', {
                    rules: [
                        {
                            required: true,
                            message: '请选择机型'
                        }
                    ]
                })(
                    <Select
                        placeholder='请选择机型'
                        allowClear
                        showSearch
                        mode="multiple"
                        filterOption={(input, option) =>
                            option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                        }
                    >
                        {modelData && modelData.map(item => <Option key={item.code}>{item.code}</Option>)}
                    </Select>
                )}
            </FormItem>
            <FormItem {...formItemLayout} label={'适用工序'}>
                {getFieldDecorator('procedure', {
                    rules: [
                        {
                            required: true,
                            message: '请选择工序'
                        }
                    ]
                })(
                    <Select
                        placeholder='请选择工序'
                        allowClear
                        showSearch
                        labelInValue
                        filterOption={(input, option) =>
                            option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
                        }
                    >
                        {procedureData && procedureData.map(item => <Option key={item.procedureCode}>{item.procedureName}</Option>)}
                    </Select>
                )}
            </FormItem>
            {/* <FormItem {...formItemLayout} label={'适用岗位'}>
                {getFieldDecorator('post', {
                    rules: [
                        {
                            required: true,
                            message: '请输入适用岗位'
                        }
                    ]
                })(<Input placeholder='请输入适用岗位' allowClear />)}
            </FormItem> */}
            <FormItem {...formItemLayout} label={'表格编码'}>
                {getFieldDecorator('tableCode', {
                    rules: [
                        {
                            required: true,
                            message: '请输入表格编码'
                        }
                    ],
                    getValueFromEvent: (event) => {
                        return event.target.value.replace(/\s+/g, "")
                    },
                })(<Input placeholder='请输入表格编码' allowClear />)}
            </FormItem>
            <FormItem {...formItemLayout} label={'状态'}>
                {getFieldDecorator('isDelete', {
                    initialValue: 0
                })(<Radio.Group>
                    {
                        StartOrStopList.map(e => {
                            return <Radio value={e.id}>{e.value}</Radio>
                        })
                    }
                </Radio.Group>)}
            </FormItem>
        </Form>
    );

}

export default Form.create()(AddSelfChecking);
